Web Design,Programming,Mobile,iOS/Android,GameDev,IT Businness,eCommerce,Social Media

Advertisement
Showing posts with label Web Programming. Show all posts
Showing posts with label Web Programming. Show all posts

Tuesday, 11 February 2014

PHP Basics - Syntax and tags


As you noticed in my first tutorial Getting Started with PHP - What is PHP ? we used opening and closing tags to start writting php commands. You will need these tags whenever you want to write php code :

<?php
  //PHP code here
?>
So the very first thing you will do when writting php code make sure you have those tags and your actual code inside. The file where you are writing php code must have the .php extension. If you think you can write these lines in an .html file and run them properly in a browser then you are wrong. PHP files have the .php extension and thus the browser recognizes them and tells the server to execute those lines of code inside the opening and closing php tags.

Basic Printing

In the first tutorial we used to print a string on screen. To do that we used the echo command. This command is used to print and show the result of anything you want to. You can print variables ( more on variables in next tutorial ), strings and other stuff. We will get into more detail in the upcoming tutorials.

Basically what we did to print that string on screen is used the echo command and the string wrapped inside double quotes.

<?php
  echo "This is a string in double quotes to be printed on screen";
?>
Pleace notice the semicolon in the end of the command. Since PHP is written in C and thus it has the syntax rules of C language. So every command that you enter, except keywords, functions, classes etc ( if you are familiar with these thats ok, but if not don't worry just continue we will get into those later on ), must end with a semicolon which means the end of the given command.

PHP can be mixed with html elements to stylize your strings. Take a look at this example

<?php
  echo "<h1>This is a h1 tag inside PHP</h1>";
?>
As you can see you can wrap your strings with actual html tags inside the double quotes in an echo command, and the result will be as we would do in plain html. You may ask yourself why whould i need to put html tags inside php commands when i can just write the html tag.

Keep in mind that PHP can do a lot more than just basic printing, and when you will get into more complex stuff, like calculations data processing and other things, you will need to retrieve those results with php commands and wrapped with html tags.

Go ahead and do some experiments with the echo command and with html tags inside, like styling them with CSS or inline CSS. You will see that the result will be as you would write plain HTML. This is the basic syntax in PHP, in the upcoming tutorials we will talk more about variables.

Getting Started with PHP - What is PHP ?

PHP Logo

Hello World. This text is meant for absolute beginners in PHP. PHP is a dynamic server sided scripting language which we can use to build simple and complex websites. Dynamic means that PHP has the ability to take decisions based on different behaviors or clicks on our website, show different portions of contents, make calculations and other great stuff.

We cannot tell how much PHP is capable of in single text, rather we will focus on how to get started with things simple PHP page and show simple text on browser.

Gathering the Tools

First of all to write code you will need an IDE with syntax highlighting and indentation. Do a search on Google for PHP IDE's and you will find plenty of them. If you are a beginner then a good choice for ( if you are a windows user ) would be Notepad++ or Programmers Notepad.

As we said PHP is server sided scripting language. Server sided means that PHP code only runs in a server with appache module and packages installed. If you don't understand what this is don't worry, just go ahead and install Xampp somewhere on your computer. This program will install binaries and other stuff including PHP which we can use to actually write PHP pages. You just start the program and start the Appache module. Open your browser and in the URL bar type localhost. If you see It Work's then you have successfully installed Xampp. Congrats !

After installing this program, navigate to your installation directory and find the htdocs folder. This is the folder where we will store our projects. Create a folder inside this folder and name it whatever you like. For simple testing purpose name it mypage, or testpage.

Writing some PHP code

Now we will write simple php code to test if PHP runs perfectly. Open your favorite editor and type this line of code and save it as index.php on your early created folder in htdocs.

<?php php_info(); ?>

In your browser type localhost/testpage or whatever you named your folder. Hopefully if you did everything as told, you will see a page with your PHP configuration settings which means that we can run PHP files correctly with the help of XAMPP.


Now delete everything on your index.php file and paste this code. Again save it and navigate to localhost/testpage to see the results.

<?php echo "Hello World, This is my first PHP page. Hurray !"; ?>

Congratulations on your first successfully programmed PHP page. Please refer to online documentation to proceed and subscribe to our blog for more awesome and simple upcoming tutorials.

Sunday, 28 April 2013

Building an E-Commerce Website

eCommerce
E-Commerce has had a tremendous rise globally. It has challenged and dramatically changed the traditional business models and value propositions of many business organizations.

People now are employing at mass E-Commerce Website to do their business electronically since Internet and the security of transactions through Internet has become mainstream. Your decision for building an E-Commerce Website would be great, and in this article we will try to explain couple of steps and points to take in consideration.


Tuesday, 26 March 2013

I want to be a Web Developer, where do i start ?

diagrams
So you have a feeling like you want to create some art on Internet that others can enjoy it ? Or maybe you have ideas that no one else can understand and you want to start on your own.

Or you have your own business you want to expand it on the internet. Whatever the reason you want to start learning how to create unique beautiful interactive websites.

Web Development is one of the most trending fields in the world of Information Technologies with the most innovation and success. Probably you want to enter this world but you have no idea where to start, how to start and what to learn. Here are some guides to get you started, if you feel yourself a complete beginner.

Saturday, 29 December 2012

Ways to protect your website from SQL Injection

SQL Injection has been around here from long time. And is one of the firsts and most successful steps hackers would take to gain control over your website. Many new developers face this problem and they are not aware of huge amount of vulnerability that sits on their website just because they do not take security seriously. In this text we will cover most useful tips to avoid being hacked from this type of attack.


Ways to create successful websites

I have been programming websites for 4 years and i have seen many ways i stuck myself in the middle of the road when my projects grow larger. And i simply want to start again fresh. But this is not the solution. Many developers face those problems and what they do is start again from the beginning, leave the whole project unfinished or finished but with huge problems. What should every developer know before taking the next step to create some robust content management systems ? In my opinion i will describe some ways to avoid these common problems and organize yourself without being lost and end up with headache.


 

© 2013 smartnoob . All rights resevered. Designed by Templateism